let parseUrl = {};

parseUrl.parse = function (module, page, query) {
    let url = `/${module}/`;
    if (page > 1) {
        if (query === '') {
            url = `/${module}/?page=${page}`;
        } else {
            if (query.charAt(query.length - 1) === '&') {
                query = query.substring(0, query.length - 1);
            }
            url = `/${module}/?page=${page}&${query}`;
        }
    } else {
        if (query !== '') {
            if (query.charAt(query.length - 1) === '&') {
                query = query.substring(0, query.length - 1);
            }
            url = `/${module}/?${query}`;
        }
    }
    return url;
};

export default parseUrl;
